package com.prj.ufdm.demo.tutorial.es;

import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;

public class ElasticMappingBuilder {

	public final static String INDEX_RES_LIB = "res_dwxx";
	public final static String INDEX_TYPE_DWXX = "DWXX";
	
	/**
	 * 构建单位信息Mapping
	 * @return
	 * @throws Exception
	 */
	public static XContentBuilder dwxxBuild() throws Exception {
		XContentBuilder builder = XContentFactory.jsonBuilder()
                .startObject()
                    .startObject("properties")
                        .startObject("dwzh")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwmc")
                        .field("type", "text")
                        .field("analyzer", "ik_max_word")
                        .field("search_analyzer", "ik_smart")
                        .endObject()
                        
                        .startObject("dwdz")
                        .field("type", "text")
                        .field("analyzer", "ik_max_word")
                        .field("search_analyzer", "ik_smart")
                        .endObject()
                        
                        .startObject("dwfrdbxm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwfrdbzjlx")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwfrdbzjhm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwlsgx")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwjjlx")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwsshy")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwyb")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwdzxx")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("jbrxm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("jbrgddhhm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("jbrsjhm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("jbrzjlx")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("jbrzjhm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("zzjgdm")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dwslrq")
                        .field("type", "date")
                        .endObject()
                        
                        .startObject("dwkhrq")
                        .field("type", "date")
                        .endObject()
                        
                        .startObject("dwfxr")
                        .field("type", "short")
                        .endObject()
                        
                        .startObject("styhmc")
                        .field("type", "keyword")
                        .endObject()
                        
                        .startObject("dqmc")
                        .field("type", "keyword")
                        .endObject()
                    .endObject()
                .endObject();
		return builder;
	}
}
